import 'package:flutter/material.dart';
import 'package:jiajia_diy/ui/drawer.dart';
import 'package:flutter/cupertino.dart';
import 'dart:async';
import 'package:sqflite/sqflite.dart';

/*
统计分析页面
用于展示diy项目的各类统计数据
 */
class StatisticalAnalysis extends StatefulWidget {
  StatisticalAnalysis({Key key, this.db}) : super(key: key);
  var db;
  @override
  State<StatefulWidget> createState() => new StatisticalAnalysisState();
}

class StatisticalAnalysisState extends State<StatisticalAnalysis> {
  var _priceTotal = 0;

  @override
  void initState() {
    super.initState();
    _getPriceTotal();
  }

  //查询总金额
  _getPriceTotal() async {
    int priceTotal = await widget.db.priceTotal();
    if (priceTotal != null) {
      setState(() {
        _priceTotal = priceTotal;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool inBoxScoll) {
          return <Widget>[
            new SliverAppBar(
              expandedHeight: 200.0,
              floating: false,
              pinned: true,
              flexibleSpace: new FlexibleSpaceBar(
                background: new Container(
                    color: Theme.of(context).primaryColor,
                ),
                title: new Text('总收入：$_priceTotal'),
                centerTitle: true,
              ),
            )
          ];
        },
        body: new Column(
        ),
      ),
    );
  }
}
